home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Devices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  12.6 KB  |  390 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Contains:    Device Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DEVICES__
  21. #define __DEVICES__
  22.  
  23.  
  24. #ifndef __OSUTILS__
  25. #include <OSUtils.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <Memory.h>                                            */
  31.  
  32. #ifndef __FILES__
  33. #include <Files.h>
  34. #endif
  35.  
  36. #ifndef __QUICKDRAW__
  37. #include <Quickdraw.h>
  38. #endif
  39. /*    #include <QuickdrawText.h>                                    */
  40.  
  41. #ifndef __EVENTS__
  42. #include <Events.h>
  43. #endif
  44.  
  45. #ifndef __DIALOGS__
  46. #include <Dialogs.h>
  47. #endif
  48. /*    #include <Errors.h>                                            */
  49. /*    #include <Windows.h>                                        */
  50. /*        #include <Controls.h>                                    */
  51. /*            #include <Menus.h>                                    */
  52. /*    #include <TextEdit.h>                                        */
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. #if PRAGMA_ALIGN_SUPPORTED
  59. #pragma options align=mac68k
  60. #endif
  61.  
  62. #if PRAGMA_IMPORT_SUPPORTED
  63. #pragma import on
  64. #endif
  65.  
  66.  
  67. enum {
  68.     chooserInitMsg                = 11,                            /* the user selected this device package */
  69.     newSelMsg                    = 12,                            /* the user made new device selections */
  70.     fillListMsg                    = 13,                            /* fill the device list with choices */
  71.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  72.     selectMsg                    = 15,                            /* the user made a selection */
  73.     deselectMsg                    = 16,                            /* the user canceled a selection */
  74.     terminateMsg                = 17,                            /* allows device package to clean up */
  75.     buttonMsg                    = 19                            /* the user selected a button */
  76. };
  77.  
  78. /* Values of the 'caller' parameter to a Chooser device package */
  79. enum {
  80.     chooserID                    = 1
  81. };
  82.  
  83. /* Values of the 'message' parameter to a Control Panel 'cdev' */
  84. enum {
  85.     initDev                        = 0,                            /*Time for cdev to initialize itself*/
  86.     hitDev                        = 1,                            /*Hit on one of my items*/
  87.     closeDev                    = 2,                            /*Close yourself*/
  88.     nulDev                        = 3,                            /*Null event*/
  89.     updateDev                    = 4,                            /*Update event*/
  90.     activDev                    = 5,                            /*Activate event*/
  91.     deactivDev                    = 6,                            /*Deactivate event*/
  92.     keyEvtDev                    = 7,                            /*Key down/auto key*/
  93.     macDev                        = 8,                            /*Decide whether or not to show up*/
  94.     undoDev                        = 9,
  95.     cutDev                        = 10,
  96.     copyDev                        = 11,
  97.     pasteDev                    = 12,
  98.     clearDev                    = 13,
  99.     cursorDev                    = 14
  100. };
  101.  
  102. /* Special values a Control Panel 'cdev' can return */
  103. enum {
  104.     cdevGenErr                    = -1,                            /*General error; gray cdev w/o alert*/
  105.     cdevMemErr                    = 0,                            /*Memory shortfall; alert user please*/
  106.     cdevResErr                    = 1,                            /*Couldn't get a needed resource; alert*/
  107.     cdevUnset                    = 3                                /* cdevValue is initialized to this*/
  108. };
  109.  
  110. /* Values of the 'message' parameter to a Monitor 'mntr' */
  111. enum {
  112.     initMsg                        = 1,                            /*initialization*/
  113.     okMsg                        = 2,                            /*user clicked OK button*/
  114.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  115.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  116.     nulMsg                        = 5,                            /*periodic event*/
  117.     updateMsg                    = 6,                            /*update event*/
  118.     activateMsg                    = 7,                            /*not used*/
  119.     deactivateMsg                = 8,                            /*not used*/
  120.     keyEvtMsg                    = 9,                            /*keyboard event*/
  121.     superMsg                    = 10,                            /*show superuser controls*/
  122.     normalMsg                    = 11,                            /*show only normal controls*/
  123.     startupMsg                    = 12                            /*code has been loaded*/
  124. };
  125.  
  126. /* control codes for DeskAccessories */
  127. enum {
  128.     goodbye                        = -1,                            /* heap being reinitialized */
  129.     killCode                    = 1,                            /* KillIO requested */
  130.     accEvent                    = 64,                            /* handle an event */
  131.     accRun                        = 65,                            /* time for periodic action */
  132.     accCursor                    = 66,                            /* change cursor shape */
  133.     accMenu                        = 67,                            /* handle menu item */
  134.     accUndo                        = 68,                            /* handle undo command */
  135.     accCut                        = 70,                            /* handle cut command */
  136.     accCopy                        = 71,                            /* handle copy command */
  137.     accPaste                    = 72,                            /* handle paste command */
  138.     accClear                    = 73                            /* handle clear command */
  139. };
  140.  
  141. /* Control/Status Call Codes */
  142. enum {
  143.     drvStsCode                    = 8,                            /* status call code for drive status */
  144.     ejectCode                    = 7,                            /* control call eject code */
  145.     tgBuffCode                    = 8                                /* set tag buffer code */
  146. };
  147.  
  148. /* miscellaneous Device Manager constants */
  149. enum {
  150.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  151.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  152.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  153.     asyncTrpBit                    = 10,                            /* trap word modifier */
  154.     noQueueBit                    = 9                                /* trap word modifier */
  155. };
  156.  
  157. /* flags used in the driver header and device control entry */
  158. enum {
  159.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  160.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  161.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  162.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  163.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  164.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  165.     dNeedLock                    = 6,                            /* set if driver must be locked in memory as soon as it is opened */
  166.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  167.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  168.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  169.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  170.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  171.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  172.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  173. };
  174.  
  175. /* run-time flags used in the device control entry */
  176. enum {
  177.     dOpened                        = 5,                            /* driver is open */
  178.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  179.     drvrActive                    = 7,                            /* driver is currently processing a request */
  180.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  181.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  182.     dOpenedMask                    = 0x0020                        /* driver is open */
  183. };
  184.  
  185. struct DRVRHeader {
  186.     short                            drvrFlags;
  187.     short                            drvrDelay;
  188.     short                            drvrEMask;
  189.     short                            drvrMenu;
  190.     short                            drvrOpen;
  191.     short                            drvrPrime;
  192.     short                            drvrCtl;
  193.     short                            drvrStatus;
  194.     short                            drvrClose;
  195.     unsigned char                    drvrName[1];
  196. };
  197. typedef struct DRVRHeader DRVRHeader;
  198.  
  199. typedef DRVRHeader *DRVRHeaderPtr, **DRVRHeaderHandle;
  200.  
  201. struct DCtlEntry {
  202.     Ptr                                dCtlDriver;
  203.     short                            dCtlFlags;
  204.     QHdr                            dCtlQHdr;
  205.     long                            dCtlPosition;
  206.     Handle                            dCtlStorage;
  207.     short                            dCtlRefNum;
  208.     long                            dCtlCurTicks;
  209.     WindowPtr                        dCtlWindow;
  210.     short                            dCtlDelay;
  211.     short                            dCtlEMask;
  212.     short                            dCtlMenu;
  213. };
  214. typedef struct DCtlEntry DCtlEntry;
  215.  
  216. typedef DCtlEntry *DCtlPtr, **DCtlHandle;
  217.  
  218. struct AuxDCE {
  219.     Ptr                                dCtlDriver;
  220.     short                            dCtlFlags;
  221.     QHdr                            dCtlQHdr;
  222.     long                            dCtlPosition;
  223.     Handle                            dCtlStorage;
  224.     short                            dCtlRefNum;
  225.     long                            dCtlCurTicks;
  226.     GrafPtr                            dCtlWindow;
  227.     short                            dCtlDelay;
  228.     short                            dCtlEMask;
  229.     short                            dCtlMenu;
  230.     SInt8                            dCtlSlot;
  231.     SInt8                            dCtlSlotId;
  232.     long                            dCtlDevBase;
  233.     Ptr                                dCtlOwner;
  234.     SInt8                            dCtlExtDev;
  235.     SInt8                            fillByte;
  236.     UInt32                            dCtlNodeID;
  237. };
  238. typedef struct AuxDCE AuxDCE;
  239.  
  240. typedef AuxDCE *AuxDCEPtr, **AuxDCEHandle;
  241.  
  242. typedef pascal long (*ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
  243.  
  244. #if GENERATINGCFM
  245. typedef UniversalProcPtr ControlPanelDefUPP;
  246. #else
  247. typedef ControlPanelDefProcPtr ControlPanelDefUPP;
  248. #endif
  249.  
  250. enum {
  251.     uppControlPanelDefProcInfo = kPascalStackBased
  252.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  253.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  254.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  255.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  256.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  257.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord*)))
  258.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long)))
  259.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr)))
  260. };
  261.  
  262. #if GENERATINGCFM
  263. #define NewControlPanelDefProc(userRoutine)        \
  264.         (ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentArchitecture())
  265. #else
  266. #define NewControlPanelDefProc(userRoutine)        \
  267.         ((ControlPanelDefUPP) (userRoutine))
  268. #endif
  269.  
  270. #if GENERATINGCFM
  271. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  272.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  273. #else
  274. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  275.         (*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  276. #endif
  277.  
  278. extern pascal DCtlHandle GetDCtlEntry(short refNum);
  279. /*
  280.     SetChooserAlert used to simply set a bit in a low-mem global
  281.     to tell the Chooser not to display its warning message when
  282.     the printer is changed. However, under MultiFinder and System 7,
  283.     this low-mem is swapped out when a layer change occurs, and the
  284.     Chooser never sees the change. It is obsolete, and completely
  285.     unsupported on the PowerPC. 68K apps can still call it if they
  286.     wish.
  287. */
  288. #if OLDROUTINENAMES && !GENERATINGCFM
  289. extern pascal Boolean SetChooserAlert(Boolean f);
  290. #endif
  291. /*
  292.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  293.           There will soon be a DriverInstall() which does the right thing.
  294.  
  295.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  296.         still exports DrvrRemove, so a macro is used to map the new name to old.
  297.  
  298. */
  299.  
  300. #if !GENERATINGCFM
  301. #pragma parameter __D0 DrvrRemove(__D0)
  302. #endif
  303. extern pascal OSErr DrvrRemove(short refNum)
  304.  ONEWORDINLINE(0xA03E);
  305. #define DriverRemove(refNum) DrvrRemove(refNum)
  306. extern pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
  307. extern pascal OSErr CloseDriver(short refNum);
  308. extern pascal OSErr Control(short refNum, short csCode, const void *csParamPtr);
  309. extern pascal OSErr Status(short refNum, short csCode, void *csParamPtr);
  310. extern pascal OSErr KillIO(short refNum);
  311.  
  312. #if !GENERATINGCFM
  313. #pragma parameter __D0 PBControlSync(__A0)
  314. #endif
  315. extern pascal OSErr PBControlSync(ParmBlkPtr paramBlock)
  316.  ONEWORDINLINE(0xA004);
  317.  
  318. #if !GENERATINGCFM
  319. #pragma parameter __D0 PBControlAsync(__A0)
  320. #endif
  321. extern pascal OSErr PBControlAsync(ParmBlkPtr paramBlock)
  322.  ONEWORDINLINE(0xA404);
  323.  
  324. #if !GENERATINGCFM
  325. #pragma parameter __D0 PBControlImmed(__A0)
  326. #endif
  327. extern pascal OSErr PBControlImmed(ParmBlkPtr paramBlock)
  328.  ONEWORDINLINE(0xA204);
  329.  
  330. #if !GENERATINGCFM
  331. #pragma parameter __D0 PBStatusSync(__A0)
  332. #endif
  333. extern pascal OSErr PBStatusSync(ParmBlkPtr paramBlock)
  334.  ONEWORDINLINE(0xA005);
  335.  
  336. #if !GENERATINGCFM
  337. #pragma parameter __D0 PBStatusAsync(__A0)
  338. #endif
  339. extern pascal OSErr PBStatusAsync(ParmBlkPtr paramBlock)
  340.  ONEWORDINLINE(0xA405);
  341.  
  342. #if !GENERATINGCFM
  343. #pragma parameter __D0 PBStatusImmed(__A0)
  344. #endif
  345. extern pascal OSErr PBStatusImmed(ParmBlkPtr paramBlock)
  346.  ONEWORDINLINE(0xA205);
  347.  
  348. #if !GENERATINGCFM
  349. #pragma parameter __D0 PBKillIOSync(__A0)
  350. #endif
  351. extern pascal OSErr PBKillIOSync(ParmBlkPtr paramBlock)
  352.  ONEWORDINLINE(0xA006);
  353.  
  354. #if !GENERATINGCFM
  355. #pragma parameter __D0 PBKillIOAsync(__A0)
  356. #endif
  357. extern pascal OSErr PBKillIOAsync(ParmBlkPtr paramBlock)
  358.  ONEWORDINLINE(0xA406);
  359.  
  360. #if !GENERATINGCFM
  361. #pragma parameter __D0 PBKillIOImmed(__A0)
  362. #endif
  363. extern pascal OSErr PBKillIOImmed(ParmBlkPtr paramBlock)
  364.  ONEWORDINLINE(0xA206);
  365. extern pascal short OpenDeskAcc(ConstStr255Param deskAccName)
  366.  ONEWORDINLINE(0xA9B6);
  367. extern pascal void CloseDeskAcc(short refNum)
  368.  ONEWORDINLINE(0xA9B7);
  369. #if CGLUESUPPORTED
  370. extern short opendeskacc(const char *deskAccName);
  371. extern OSErr opendriver(const char *driverName, short *refNum);
  372. #endif
  373. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  374. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  375. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  376.  
  377. #if PRAGMA_IMPORT_SUPPORTED
  378. #pragma import off
  379. #endif
  380.  
  381. #if PRAGMA_ALIGN_SUPPORTED
  382. #pragma options align=reset
  383. #endif
  384.  
  385. #ifdef __cplusplus
  386. }
  387. #endif
  388.  
  389. #endif /* __DEVICES__ */
  390.